package com.elitel.frame.base.component.quartz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 程序启动后执行quartz任务调度
 * created by guoyanfei on 2018/4/26
 */
@Component
@Order(value = 1)
public class TaskRunner implements ApplicationRunner {
    @Autowired
    private SearchServiceTask searchServiceTask;

    //程序启动是否需要执行
    @Value("${elitel.task.perform}")
    private Boolean perform;

    /**
     * 执行全文检索任务调度(包括数据库和非结构化文档)
     * created by guoyanfei on 2018/04/26
     * @param applicationArguments
     * @throws Exception
     */
    @Override
    public void run(ApplicationArguments applicationArguments) throws Exception {
        if(perform){
            searchServiceTask.startSearchServiceScheduler("");
            searchServiceTask.startSearchDocumentScheduler("");
            searchServiceTask.startQueryDataByCacheConfigScheduler(null, null, null);
        }
    }

}
